using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.Data.SqlClient;

/// <summary>
/// Summary description for MonTienQuyetDAO
/// </summary>
public class MonTienQuyetDAO:DataProvider
{
	public MonTienQuyetDAO()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    public ArrayList LayMang_MonTQ(int maMonHoc)
    {
        connect();
        ArrayList arr = new ArrayList();
        try
        {
            SqlCommand cmd = new SqlCommand("sp_Select_MonTienQuyet", strCnn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@maMonHoc", SqlDbType.NVarChar);
            cmd.Parameters["@maMonHoc"].Value = maMonHoc.ToString();
            SqlDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                MonTienQuyetDTO montqdto = new MonTienQuyetDTO();
                montqdto.MaMonHoc = dr.GetInt32(0);
                montqdto.MaMonTienQuyet = dr.GetInt32(1);
                arr.Add(montqdto);
            }


        }
        catch (Exception es)
        {
            throw es;
        }
        return arr;
    }

    public void insert(MonTienQuyetDTO montqdto)
    {
        connect();
        ArrayList arr = new ArrayList();
        try
        {
            SqlCommand cmd = new SqlCommand("sp_Insert_MonTienQuyet", strCnn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@maMonHoc", SqlDbType.Int);
            cmd.Parameters["@maMonHoc"].Value = montqdto.MaMonHoc;
            cmd.Parameters.Add("@maMonTQ ", SqlDbType.Int);
            cmd.Parameters["@maMonTQ "].Value = montqdto.MaMonTienQuyet;
            cmd.ExecuteNonQuery();
        }
        catch (Exception es)
        {
            throw es;
        }
    }
}
